package top.oneit.jdownload.data.dao;

import cn.hutool.core.collection.CollUtil;
import org.hibernate.Session;
import top.oneit.jdownload.data.entity.DownloadFile;

import java.util.List;

/**
 * @author lingkang
 * @date 2021/11/21
 */
public class DownloadFileDao extends BaseDao{

    public static DownloadFile getLast(){
        Session session = getSession();
        session.beginTransaction();
        List<DownloadFile> list = session.createQuery("from DownloadFile order by createTime desc")
                .setFirstResult(0).setMaxResults(1).list();
        session.getTransaction().commit();
        if (CollUtil.isEmpty(list)){
            return null;
        }
        return list.get(0);
    }

}
